<!DOCTYPE html>
<html>
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>大客户拜访记录</title>
    <!--{include file='comm/comm_cal.tpl'}-->

    <!--引用div做成的下拉框效果样式-->
    <link rel="stylesheet" href="/quanliadmin/docroot/css/department_select.css" type="text/css" media="screen" />
    <!--引用div做成的下拉框效果js-->
    <script language="JavaScript" src="/quanliadmin/docroot/js/department_select.js" type="text/javascript"></script>
</head>
<body>

<div class="container">

    <div class="comm_content">
        <div class="search-box">
            <div style="position:relative">
                <form class="form-inline" id="search_form" onsubmit="return false;">
                    <table style="table-layout:fixed;width:100%;">
                        <tbody>
                        <tr>
                            <td>
                                <span>公司名称：
                                    <input type="text"  class="form-control input-sm" name="company_name" id="company_name" style="width:150px;"/>
                                </span>
                                <span>联系人：
                                    <input type="text"  class="form-control input-sm" name="contacts" id="contacts" style="width:150px;"/>
                                </span>
                                <span>部 门：</span>
                                <span style="vertical-align: middle">
                                    <div class="search_option" style="width: 200px">
                                        <div class="search_option_drop">
                                            <span id="searchOptions">
                                                请选择
                                            <font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>
                                            </span>
                                        </div>
                                        <ul class="search_option_panel"  id="searchPanels" style="display: none;z-index: 100;">
                                            <li class="childSelectImg" departmentID="" style="margin-top:5px;margin-bottom:5px;margin-left: 0px;font-size: 13px;" >请选择</li>
                                            <!--{$department_select_html}-->
                                        </ul>

                                        <input type="hidden" value="0" id="hdnSearchTypes" name="hdnSearchType">
                                        <input type="hidden" value="" id="search_departmentID" name="search_departmentID">
                                    </div>
                                </span>
                                <span>销售员：
                                    <select class="form-control w150" id="userID" name="userID">
                                        <option value="">请选择</option>
                                    </select>
                                </span>
                                <span>
                                    <button type="button" class="btn btn-primary" id="searchBtn" onclick="search();">查询</button>
                                </span>
                                <span>
                                    <button type="button" class="btn btn-warning" id="clearBtn" onclick="clearUp();" >重置</button>
                                </span>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>

        <table id="flex" style="display:none"></table>

    </div>

</div>

<script type="text/javascript">
    $(function () {
        $('#searchPanels').find('li').click(function() {
            var departmentID = $(this).attr('departmentID');
            if (departmentID > 0) {
                E.ajax_get({
                    url: '/invokingAjax-backend/company/company.ajax?operFlg=2',
                    data: {
                        departmentID: departmentID
                    },
                    call: function( o ) {
                        if (o.code == 200) {
                            var html = '<option value="">请选择</option>';
                            if ( o.data ) {
                                $.each( o.data, function( k, v ) {
                                    html += '<option value="' + v.userID + '">' + v.trueName + '</option>';
                                });
                            }
                            $('#userID').html(html);

                        } else {
                            E.alert( o.message);
                        }
                    }
                });
            } else {
                var html = '<option value="">请选择</option>';
                $('#userID').html(html);
            }
        });
    });

    $("#flex").flexigrid({
        url:"/invokingAjax-backend/company/company.ajax?operFlg=4",
        dataType: "json",
        colModel : [
            {display: "公司名称", width : 100},
            {display: "拜访人", width : 80},
            {display: "拜访时间", width : 80},
            {display: "联系人", width : 80},
            {display: "联系电话", width : 80},
            {display: "地点", width : 150},
            {display: "拜访内容", width: 200},
            {display: "问题反馈", width: 200},
            {display: "意见与建议", width: 200}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "openAdd"},
        ],
        usepager: true,
        rp: 10,
        useRp: true,
    });

    function load () {
        $("#flex").flexReload();
    }

    function search() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({params: dt}).flexReload();
    }

    function clearUp() {
        $('#company_name').val('');
        $('#contacts').val('');
        $("#search_departmentID").val('');
        $("#userID").val('');
        var searchOptions= "请选择" +'<font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
        $('#searchOptions').html( searchOptions );
        search();
    }

    function openAdd () {
        E.open("/quanliadmin/app/company/company.pscript?operFlg=4", "", {height: 620,width: 1024, top: 10, left: 150});
    }

</script>

</body>

</html>